'use server'; import View from './view'; import { notFound, forbidden, unauthorized } from 'next/navigation'; import { isAuthenticated } from '@/lib/api/auth'; import { fetchBoard, fetchBoardList } from '@/lib/api/forum/board'; import { fetchPostData } from '@/lib/api/forum/post'; import { getTokenData } from '@/lib/utils/server'; import { TokenData } from '@/dtos/response/common'; export default async function PostEdit({ params }: { params: Promise<{ id: string }> }) { const { id } = await params; if (!/^\d+$/.test(id)) { return forbidden(); } let tokenData: TokenData|null; try { if (!await isAuthenticated()) { throw Error; } // 회원 정보 조회 tokenData = await getTokenData(); if (!tokenData) { throw Error; } console.log(tokenData); } catch { return unauthorized(); } try { // 게시글 정보 조회 const post = await fetchPostData(Number(id)); if (!post.success || !post.data) { throw Error; } // 게시판 상세 조회 const board = await fetchBoard(post.data.boardCode); if (!board.success || !board.data) { throw Error; } // 게시판 목록 조회 const boardList = await fetchBoardList(board.data.boardGroup.code); if (!boardList.success || !boardList.data) { return notFound(); } return ( ); } catch { return notFound(); } }